home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
cbibcode.arc
/
ECVT.C
< prev
next >
Wrap
Text File
|
1991-08-05
|
812b
|
25 lines
/* ecvt.c, from pp.173-174 of Turbo C Bible */
/* Converts a double-precision floating-point value into a string without
an embedded decimal point (the sign of the value and the position of
the decimal point are returned separately). */
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
main(int argc, char **argv)
{
int dec, sign, precision = 10;
double value;
char *p_buffer;
if(argc < 2)
{
printf("Usage: %s <value>\n", argv[0]);
}
else
{ /* Convert the number to internal */
value = atof(argv[1]);/* form. Then call ecvt. */
p_buffer = ecvt(value, precision, &dec, &sign);
printf("Buffer from ecvt contains: %s\n"
"Location of decimal point: %d\n"
"Sign(0 = pos, 1 = neg) : %d\n", p_buffer, dec, sign);
}
}